#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
        ListNode* cur1 = l1, * cur2 = l2;
        int enter = 0;
        ListNode* newHead = new ListNode;
        ListNode* tail = newHead;
        while (cur1 || cur2 || enter) {
            if (cur1) {
                enter += cur1->val;
                cur1 = cur1->next;
            }
            if (cur2) {
                enter += cur2->val;
                cur2 = cur2->next;
            }
            tail->next = new ListNode(enter % 10);
            enter /= 10;
            tail = tail->next;
        }
        tail = newHead->next;
        return tail;
    }
};